<?php

// $Id$

global $WSC;

require_once($WSC->get_site_inc_dir().'modules/web_site_jabba/jabba_web_page.class.php');
require_once($WSC->get_site_inc_dir().'modules/tangra_cms/_sys/tcms_web_page_view.class.php');


class Tangra_CMS_WP extends Chocolate_Web_Page {
	public function init() {
		parent::init();

		$v = new TCMS_Web_Page_View($this, 'default', 'pages/');
		$this->add_view($v);
	}


	public function run() {
		$context = $this->get__context();
		$uri = $context->get_from_server('REQUEST_URI');
		$this->export('uri', urldecode($uri));
		$ret = $this->get_view('default');
//		$ret->add_http_header('HTTP/1.0 404 Page not found');
		$this->log_not_found($uri);

		return $ret;
	}


	private function log_not_found($uri) {
		$config = $this->get__config();

		$log_dir = $config->get_logs_dir();
		$not_found_log = $log_dir.'not_found.log';
		error_log(date('Y-m-d H:i:s')." $uri\r\n", 3, $not_found_log);
		@chmod($not_found_log, 0660);
	}
}